package com.sentrix.auto.printercenter.application;

import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryCondition;
import com.sentrix.auto.printercenter.domain.entity.PrinterTaskEntity;
import com.sentrix.auto.printercenter.infrastructure.persistence.IPrinterTaskRepository;
import com.sentrix.auto.printercenter.presentation.center.dto.PrinterTaskPageQueryReqDto;
import com.sentrix.auto.printercenter.presentation.center.dto.PrinterTaskResDto;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.function.Function;

@Service
@Transactional(readOnly = true)
public class PrinterTaskQueryService {

    @Resource
    private IPrinterTaskRepository printerTaskRepository;

    public <R> Page page(PrinterTaskPageQueryReqDto param, Function<PrinterTaskEntity, R> convert) {
        Page<PrinterTaskEntity> page = printerTaskRepository.pageQuery(param.getPageParam().getCurrentPage(), param.getPageParam().getPageSize(), param.getOrderNo(), param.getPrinterCode(), param.getAgentName(), param.getPrinterName());
        return page.map(convert);
    }
}
